'use strict';
define(function(require, exports, module) {

	exports.stateRoute = function(app, name, url, tplUrl, modelUrl) {
		app.config(function($stateProvider, $urlRouterProvider) {
			$stateProvider.state(name, {
				url: url,
				templateUrl: tplUrl,
				controller: function($scope, $timeout) {
					require.async(modelUrl, function(model) {
						$timeout(function() {
							model.controller(app, $scope);
							
							if (!$scope.$$phase) {
								$scope.$apply();
							}
						});
					});
				}
			});
		});
	};

});